<template>
	<view class="upgrade-view">
		<upgrade ref="upgrade" />
	</view>
</template>

<script>
import { store } from '@/api/service/store-service.js'
import Upgrade from '@/components/upgrade/upgrade.vue'

export default {
  components: {
    Upgrade
  },

	onLoad (params) {
		this.params = params || {}
	},

	async onShow () {
		let data = await store.getItem('upgrade-data')
		// 下载更新
		let view = this.$refs.upgrade
		let url = view.getDownloadUrl(data)
		view.download(url).then(b =>{
			if (b === false) {
				if (this.params.source === 'workbench') {
					uni.reLaunch({
						url: '/pages/sys/workbench/index'
					})
				} else {
					this.goBack()
				}
			}
		})
	}
}
</script>

<style>

</style>
